#include "StdAfx.h"
#include "MyRichEditBox.h"


MyRichEditBox::MyRichEditBox(void)
{
}


MyRichEditBox::~MyRichEditBox(void)
{
}


HWND MyRichEditBox::createRichEditBox(LPCWSTR text,int styles,int x, int y, int cx,int cy, HWND hParent, int id ,
	int nHeight,int fnWeight , BOOL fdwItalic , BOOL fdwUnderline, LPTSTR font, HINSTANCE hInst)
{
	InitCommonControls();

	reLib = LoadLibrary(L"riched32.dll");
	if(!reLib)
		MessageBox(hRichEditBox,L"Failed to load riched32.dll!",L"Error when load library!",MB_ICONEXCLAMATION);

	hInstance = hInst;
	hRichEditBox = CreateWindowEx(WS_EX_CLIENTEDGE,RICHEDIT_CLASS,text,styles,x,y,cx,cy,hParent,(HMENU)id,hInst,0);

	HFONT hFont = CreateFont(nHeight,0,0,0,fnWeight,fdwItalic,fdwUnderline,0,VIETNAMESE_CHARSET,OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, VARIABLE_PITCH,font);

	SendMessage(hRichEditBox,WM_SETFONT,(WPARAM)hFont, 0);

	CRichEditThemed::Attach(hRichEditBox);
	return hRichEditBox;
}

void MyRichEditBox::setText (LPWSTR text)
{
	SetWindowText(hRichEditBox,text);
}
LPWSTR MyRichEditBox::getText ()
{
	LPWSTR temp = new WCHAR[256];
	GetWindowText(hRichEditBox,temp,256);
	return temp;
}
HWND MyRichEditBox::getHandle()
{
	return hRichEditBox;
}


void MyRichEditBox::hide()
{
	ShowWindow(hRichEditBox,SW_HIDE);
}

void MyRichEditBox::show()
{
	ShowWindow(hRichEditBox,SW_SHOW);
}


void MyRichEditBox::move(int x, int y, int cx, int cy)
{
	MoveWindow(hRichEditBox,x, y, cx, cy,TRUE);
}
